package com.meida.module.marketing.provider.service.impl;

import com.meida.common.mybatis.base.service.impl.BaseServiceImpl;
import com.meida.common.mybatis.entity.EntityMap;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.common.utils.FlymeUtils;
import com.meida.module.marketing.client.entity.MkgCoupon;
import com.meida.module.marketing.provider.mapper.CouponMapper;
import com.meida.module.marketing.provider.service.CouponService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 优惠券Service实现类
 *
 * @author flyme
 * @date 2019-10-22
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class CouponServiceImpl extends BaseServiceImpl<CouponMapper, MkgCoupon> implements CouponService {


    @Override
    public ResultBody beforePageList(CriteriaQuery<MkgCoupon> cq, MkgCoupon mkgCoupon, EntityMap requestMap) {
        if (FlymeUtils.isNotEmpty(mkgCoupon)) {
            cq.eq("couponTitle", mkgCoupon.getCouponTitle());
            cq.eq("state", mkgCoupon.getState());
            cq.ge("expiryBeginTime", mkgCoupon.getExpiryBeginTime());
            cq.le("expiryEndTime", mkgCoupon.getExpiryEndTime());
        }
        return ResultBody.ok();
    }
}
